home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP06.ZIP / CHAP06 / FREELOAD / FREELOAD.CPP < prev    next >
C/C++ Source or Header  |  1993-06-15  |  3KB  |  149 lines

  1. /*
  2.  * FREELOAD.CPP
  3.  *
  4.  * Freeloader application that uses the OLE 2.0 Default Object Handler
  5.  * to provide free drawing and serialization services for bitmaps and
  6.  * metafiles.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18.  
  19. #define INITGUIDS
  20. #include "freeload.h"
  21.  
  22.  
  23. /*
  24.  * WinMain
  25.  *
  26.  * Purpose:
  27.  *  Main entry point of application.   Should register the app class
  28.  *  if a previous instance has not done so and do any other one-time
  29.  *  initializations.
  30.  */
  31.  
  32. int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pszCmdLine, int nCmdShow)
  33.     {
  34.     LPCFreeloaderFrame  pFR;
  35.     FRAMEINIT           fi;
  36.     WPARAM              wRet;
  37.  
  38.    #ifndef WIN32
  39.     SetMessageQueue(96);
  40.    #endif
  41.  
  42.     //Attempt to allocate and initialize the application
  43.     pFR=new CFreeloaderFrame(hInst, hPrev, pszCmdLine, nCmdShow);
  44.  
  45.     fi.idsMin=IDS_STANDARDFRAMEMIN;
  46.     fi.idsMax=IDS_STANDARDFRAMEMAX;
  47.     fi.idsStatMin=IDS_STANDARDSTATMESSAGEMIN;
  48.     fi.idsStatMax=IDS_STANDARDSTATMESSAGEMAX;
  49.     fi.idStatMenuMin=ID_MENUFILE;
  50.     fi.idStatMenuMax=ID_MENUHELP;
  51.     fi.iPosWindowMenu=WINDOW_MENU;
  52.     fi.cMenus=CMENUS;
  53.  
  54.     //If we can initialize pFR, start chugging messages
  55.     if (pFR->FInit(&fi))
  56.         wRet=pFR->MessageLoop();
  57.  
  58.     delete pFR;
  59.     return wRet;
  60.     }
  61.  
  62.  
  63.  
  64.  
  65.  
  66. /*
  67.  * CFreeloaderFrame::CFreeloaderFrame
  68.  * CFreeloaderFrame::~CFreeloaderFrame
  69.  *
  70.  * Constructor Parameters:
  71.  *  hInst           HINSTANCE from WinMain
  72.  *  hInstPrev       HINSTANCE from WinMain
  73.  *  pszCmdLine      LPSTR from WinMain
  74.  *  nCmdShow        int from WInMain
  75.  */
  76.  
  77. CFreeloaderFrame::CFreeloaderFrame(HINSTANCE hInst, HINSTANCE hInstPrev
  78.     , LPSTR pszCmdLine, int nCmdShow)
  79.     : CFrame(hInst, hInstPrev, pszCmdLine, nCmdShow)
  80.     {
  81.     m_fInitialized=FALSE;
  82.     return;
  83.     }
  84.  
  85.  
  86. CFreeloaderFrame::~CFreeloaderFrame(void)
  87.     {
  88.     if (m_fInitialized)
  89.         OleUninitialize();
  90.  
  91.     return;
  92.     }
  93.  
  94.  
  95.  
  96.  
  97. /*
  98.  * CFreeloaderFrame::FInit
  99.  *
  100.  * Purpose:
  101.  *  Call CoInitialize then calling down into the base class
  102.  *  initialization.
  103.  *
  104.  * Parameters:
  105.  *  pFI             LPFRAMEINIT containing initialization parameters.
  106.  *
  107.  * Return Value:
  108.  *  BOOL            TRUE if initialization succeeded, FALSE otherwise.
  109.  */
  110.  
  111. BOOL CFreeloaderFrame::FInit(LPFRAMEINIT pFI)
  112.     {
  113.     DWORD       dwVer;
  114.  
  115.     dwVer=OleBuildVersion();
  116.  
  117.     if (rmm!=HIWORD(dwVer))
  118.         return FALSE;
  119.  
  120.     if (FAILED(OleInitialize(NULL)))
  121.         return FALSE;
  122.  
  123.     m_fInitialized=TRUE;
  124.  
  125.     return CFrame::FInit(pFI);
  126.     }
  127.  
  128.  
  129.  
  130.  
  131.  
  132. /*
  133.  * CFreeloaderFrame::CreateCClient
  134.  *
  135.  * Purpose:
  136.  *  Constructs a new client specific to the application.
  137.  *
  138.  * Parameters:
  139.  *  None
  140.  *
  141.  * Return Value:
  142.  *  LPCClient       Pointer to the new client object.
  143.  */
  144.  
  145. LPCClient CFreeloaderFrame::CreateCClient(void)
  146.     {
  147.     return (LPCClient)(new CFreeloaderClient(m_hInst));
  148.     }
  149.